package com.fsgom.gool.repository;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.util.CollectionUtils;

import com.fsgom.gool.bean.GoolArtcl;
import com.fsgom.gool.bean.GoolArtclInfo;
import com.fsgom.gool.bean.GoolArtclRcmd;

@Repository
public class GoolArtclRepositoryImpl implements GoolArtclRepository {

	private static final String NAMESPACE = GoolArtclRepositoryImpl.class.getName() + ".";
	
	@Autowired
	private SqlMapClientTemplate client;
	
	@SuppressWarnings("unchecked")
	@Override
	public GoolArtclInfo selectArtclInfo(int userSeq) {
		List<GoolArtclInfo> artclInfos = client.queryForList(NAMESPACE + "selectArtclInfo", userSeq);
		if (!CollectionUtils.isEmpty(artclInfos)) {
			return artclInfos.get(0);
		}
		return null;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<GoolArtcl> selectArtclLst(Map<String, Object> params) {
		return client.queryForList(NAMESPACE + "selectArtclList", params);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<GoolArtclRcmd> selectArtclRcmd(Map<String, Object> params) {
		return client.queryForList(NAMESPACE + "selectArtclRcmd", params);
	}

	@Override
	public void insertArtcl(Map<String, Object> params) {
		client.insert(NAMESPACE + "insertArtcl", params);
	}

	@Override
	public void updateArtcl(Map<String, Object> params) {
		client.update(NAMESPACE + "updateArtcl", params);
	}

	@Override
	public void insertArtclRcmd(Map<String, Object> params) {
		client.insert(NAMESPACE + "insertArtclRcmd", params);
	}

	@Override
	public void updateArtclRcmd(Map<String, Object> params) {
		client.update(NAMESPACE + "updateArtclRcmd", params);
	}

}
